package com.yqzl.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yqzl.entity.Userinfo;
import com.yqzl.mapper.User_infoMapper;
import com.yqzl.service.User_infoService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class User_infoServiceImpl extends ServiceImpl<User_infoMapper, Userinfo> implements User_infoService {
  @Resource
  User_infoMapper user_infoMapper;

  //   根据 Uid 获取用户信息
  public Userinfo getUserinfoByUid(String uId) {
    QueryWrapper<Userinfo> userinfoQueryWrapper = new QueryWrapper<>();
    userinfoQueryWrapper.eq("uid", uId);
    Userinfo userinfo = user_infoMapper.selectOne(userinfoQueryWrapper);
    return userinfo;
  }

  //   根据 Uid 更新图片信息
  public void updateImageByUid(String uId, String imagepath) {
    QueryWrapper<Userinfo> userinfoQueryWrapper = new QueryWrapper<>();
    userinfoQueryWrapper.eq("uid", uId);

    Userinfo userinfo = new Userinfo();
    userinfo.setImagepath(imagepath);
//     动态sql
    user_infoMapper.update(userinfo, userinfoQueryWrapper);
  }
}
